<?php
/**
 * Created by PhpStorm.
 * User: wangan
 * Date: 2018/7/24
 * Time: 17:41
 */

namespace app\commom\lib;


use think\facade\Config;

class Redis
{
    private static $instance = null;
    public static $redis = null;

    public static function getInstance(){
        if(self::$instance == null){
            self::$instance = new self();
        }
        return self::$instance;
    }

    public function getRedis(){
        return self::$redis;
    }

    private function __construct(){
        $host = config('redis.host');
        $port = config('redis.port');
        $passwd = config('redis.passwd');

        $redis = new \Swoole\Coroutine\Redis();
        $redis->connect($host, $port);
        $redis->auth($passwd);

        self::$redis = $redis;
    }

    private function __clone(){

    }


}